import axios from 'axios';


// 发送验证码的请求
export const sendCode = async (email: string) => {
  try {
    const response = await axios.post(`http://localhost:8080/user/send`, { email });
    return response.data; // 处理返回的数据
  } catch (error) {
    throw new Error('发送验证码失败');
  }
};

// 用户注册请求
export const register = async (data: { username: string, password: string, email: string, verificationCode: string }) => {
  // try {
  //   const response = await axios.post(`http://localhost:8080/user/register`, formData);
  //   return response.data; // 处理返回的数据
  // } catch (error) {
  //   throw new Error('注册失败');
  // }
  return axios({
    url: `http://localhost:8080/user/register`,
    method: "post",
    data
  })
};
